/*
 * Inventory.java
 *
 * Created on May 2, 2008, 6:51 AM
 */

package RPack;

import javax.swing.ButtonGroup;

/**
 *
 * @author  Administrator
 */

    class Stock{
        public static int potion;
        public static int hipotion;
        public static int ether;
        public static int hiether;
        public static int bomb;
    }
    
public class Inventory extends javax.swing.JFrame {
    
    public void run() {
                new Inventory().setVisible(true);
    }
    
    /** Creates new form Inventory */
    public Inventory() {
        initComponents();
        ButtonGroup itemlist = new ButtonGroup();
        itemlist.add(potion);
        itemlist.add(hipotion);
        itemlist.add(ether);
        itemlist.add(hiether);
    }
    

    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        jButton1 = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        potion = new javax.swing.JRadioButton();
        hipotion = new javax.swing.JRadioButton();
        ether = new javax.swing.JRadioButton();
        hiether = new javax.swing.JRadioButton();
        jSeparator2 = new javax.swing.JSeparator();
        jButton2 = new javax.swing.JButton();

        jButton1.setText("Open Pack");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        potion.setText("Potion");
        potion.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        potion.setMargin(new java.awt.Insets(0, 0, 0, 0));
        potion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                potionActionPerformed(evt);
            }
        });

        hipotion.setText("Hi-Potion");
        hipotion.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        hipotion.setMargin(new java.awt.Insets(0, 0, 0, 0));
        hipotion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                hipotionActionPerformed(evt);
            }
        });

        ether.setText("Ether");
        ether.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        ether.setMargin(new java.awt.Insets(0, 0, 0, 0));
        ether.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                etherActionPerformed(evt);
            }
        });

        hiether.setText("Hi-Ether");
        hiether.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        hiether.setMargin(new java.awt.Insets(0, 0, 0, 0));
        hiether.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                hietherActionPerformed(evt);
            }
        });

        jButton2.setText("Use Item");

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jSeparator1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 105, Short.MAX_VALUE)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .addContainerGap(12, Short.MAX_VALUE)
                .add(jButton1)
                .addContainerGap())
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(potion)
                .addContainerGap(48, Short.MAX_VALUE))
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(hipotion)
                .addContainerGap(34, Short.MAX_VALUE))
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(ether)
                .addContainerGap(52, Short.MAX_VALUE))
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(hiether)
                .addContainerGap(38, Short.MAX_VALUE))
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(jButton2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 85, Short.MAX_VALUE)
                .addContainerGap())
            .add(jSeparator2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 105, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(jButton1)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jSeparator1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(potion)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(hipotion)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(ether)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(hiether)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jSeparator2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jButton2)
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void hietherActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hietherActionPerformed
// TODO add your handling code here:
                    if(Stock.hiether>0){
                Stock.hiether = Stock.hiether - 1;
                Dungeon.manapoints = Dungeon.manapointsmax;
            } 
        else{
            setVisible(false);
        }
    }//GEN-LAST:event_hietherActionPerformed

    private void etherActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_etherActionPerformed
// TODO add your handling code here:
         if(Stock.ether>0){
            Stock.ether = Stock.ether - 1;
            Dungeon.manapoints = Dungeon.manapoints + 10;
            if(Dungeon.manapoints>Dungeon.manapointsmax)
            {
                Dungeon.manapoints = Dungeon.manapointsmax;
            }
            else{}
        }
        
        else{
            setVisible(false);
        }
    }//GEN-LAST:event_etherActionPerformed

    private void hipotionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hipotionActionPerformed
// TODO add your handling code here:
            if(Stock.hipotion>0){
                Stock.hipotion = Stock.hipotion - 1;
                Dungeon.hitpoints = Dungeon.hitpointsmax;
            } 
        else{
            setVisible(false);
        }
    }//GEN-LAST:event_hipotionActionPerformed

    private void potionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_potionActionPerformed
// TODO add your handling code here:
        if(Stock.potion>0){
            Stock.potion = Stock.potion - 1;
            Dungeon.hitpoints = Dungeon.hitpoints + 10;
            if(Dungeon.hitpoints>Dungeon.hitpointsmax)
            {
                Dungeon.hitpoints = Dungeon.hitpointsmax;
            }
            else{}
        }
        
        else{
            setVisible(false);
        }
    }//GEN-LAST:event_potionActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
        potion.setText("Potion x" +Stock.potion);
        hipotion.setText("Hi-Potion x" +Stock.hipotion);
        ether.setText("Ether x" +Stock.ether);
        hiether.setText("Hi-Ether x" +Stock.hiether);
    }//GEN-LAST:event_jButton1ActionPerformed
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Inventory().setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JRadioButton ether;
    private javax.swing.JRadioButton hiether;
    private javax.swing.JRadioButton hipotion;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JRadioButton potion;
    // End of variables declaration//GEN-END:variables
    
}
